package cn.net.isir.controller.manager;

import cn.net.isir.common.ResultObject;
import cn.net.isir.core.BasicController;
import cn.net.isir.core.SetBasicService;
import cn.net.isir.entity.Goods;
import cn.net.isir.service2.GoodsService;
import cn.net.isir.utils.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

/**
 * @author liuxubo
 * @filename GoodsController.java
 * @package cn.net.isir.controller.manager
 * @email lxb@isir.net.cn
 * @date 2018/12/04
 * @comment
 * @since 1.8
 */
@RestController
@RequestMapping("/goods")
public class GoodsController extends BasicController<Goods> {
    @SetBasicService
    @Resource
    private GoodsService goodsService;

    /**
     * 根据用户id查询信息
     *
     * @param goods userid放在
     * @return 列表
     */
    @Override
    public ResultObject selectListByUser(Goods goods) {
        try {
            if (StringUtils.isNotBlank(goods.getName())) {
                goods.setName(URLDecoder.decode(goods.getName(), StandardCharsets.UTF_8.name()));
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return super.selectListByUser(goods);
    }
}
